<!-- 我的表格 -->

<template>
  <WebTable>
    <RowIndex />

    <RowDict label="系统类型" bind="configType" :dict="DICT.TYPE" />

    <RowTime label="上传时间" bind="uploadTime" />

    <RowNum label="版本号" bind="configVersion" />

    <RowText label="备注" bind="remark" :minWidth="160" />

    <RowSlot label="模型文件" bind="modelSubUrl">
      <template #default="{ row, bind, label }">
        <a v-if="row[bind]" v-bind="getDownProps(row, bind, label)">下载</a>
      </template>
    </RowSlot>

    <RowSlot label="源文件" bind="originSubUrl">
      <template #default="{ row, bind, label }">
        <a v-if="row[bind]" v-bind="getDownProps(row, bind, label)">下载</a>
      </template>
    </RowSlot>

    <RowPhoto label="预览图" bind="previewSubUrl" :pathTrans="(path) => CORE._3Dfile(path)" />

    <RowOperate :btns="['del']" :width="80" />
  </WebTable>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyTable',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb()],

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 获取下载属性
     */
    getDownProps(row, bind, label) {
      const typeName = CORE.dict(this.DICT.TYPE, row.configType)
      return {
        href: CORE._3Dfile(row[bind]),
        download: `${typeName}${label}-${row.configVersion}`,
        class: 'el-link el-link--primary',
        target: '_blank',
      }
    },
  },
}
</script>
